package gat.api.rest.background.backgroundUser;

import java.util.List;

import gat.api.config.annotation.CheckPermissions;
import gat.api.config.annotation.Log;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.bitsun.core.common.web.ResultDTO;

import gat.api.background.backgroundUser.BRolePermissionsApi;
import gat.application.backgroundUser.RolePermissionsService;
import gat.dto.req.backgroundUser.RolePermissionsReqDto;
import gat.dto.res.backgroundUser.RolePermissionsResDto;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;

/**
 * 权限角色关联表
 * @Author: tmac
 * @Email: tmac
 */
@Slf4j
@SuppressWarnings("unchecked")
@RestController
@RequestMapping("/permissionsRole")
public class BRolePermissionsApiController implements BRolePermissionsApi {


    @Autowired
    private RolePermissionsService rolePermissionsService;

    @Override
    @Log(value = "角色关联菜单")
    @CheckPermissions(value = "rolePermissions:save")
    @PostMapping(consumes = {"application/json"}, produces = {"application/json"})
    public ResultDTO<List<RolePermissionsResDto>> addPermissionsRole(
            @ApiParam(value = "要保存的对象", required = true) @RequestBody RolePermissionsReqDto reqDto) {
        List<RolePermissionsResDto> resDtos = rolePermissionsService.save(reqDto);
        return ResultDTO.ok(resDtos);
    }

}
